package collection.test;


import java.util.ArrayList;
import java.util.Collection;

public class Demo {
    public static void main(String[] args) {
        String s = "hello";
        int a = 1;
        Point p = new Point(1,2);
        Collection c = new ArrayList();
        c.add(p);
        test(s,a,p,c);
        System.out.println("s:"+s);//?  hello
        System.out.println("a:"+a);//?  1
        System.out.println("p:"+p);//?  (3,2)
        System.out.println("c:"+c);//?  [(7,5)]
    }
    public static void test(String s,int a,Point p,Collection c) {
        //在栈中的栈帧中有s,a,p,c三个局部变量(除a外,都存放的是传入的地址)  聊天室
        a++;
        s = s + "world";
        //局部p存放的地址是传入的p的地址
        p.setX(3);
//        System.out.println(System.identityHashCode(p));
        //局部p存放的地址是新Point对象(4,5)的地址
        p = new Point(4,5);

//        System.out.println(System.identityHashCode(p));
        c.clear();
        c.add(p);
        c = new ArrayList();
        p.setX(7);
        c.add(p);
    }
}
